<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增商户')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-station-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户全称：</label>
                <div class="col-sm-8">
                    <input name="stationName" class="form-control" type="text" maxlength="60" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户简称：</label>
                <div class="col-sm-8">
                    <input name="stationShortName" class="form-control" type="text" maxlength="40" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户地址：</label>
                <div class="col-sm-8">
                    <input name="stationAddress" class="form-control" type="text" maxlength="80" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户联系电话：</label>
                <div class="col-sm-8">
                    <input name="stationPhone" class="form-control" type="text" maxlength="20">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">经度：</label>
                <div class="col-sm-8">
                    <input name="longitude" class="form-control" type="text" maxlength="12">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">纬度：</label>
                <div class="col-sm-8">
                    <input name="latitude" class="form-control" type="text" maxlength="12">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户介绍：</label>
                <div class="col-sm-8">
                    <textarea name="stationIntroduce" maxlength="500" class="form-control" rows="3"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control m-b" required>
                        <!-- 状态（0:正常; -1：禁用; -2:删除;1-待开通） -->
                        <option value="0">正常</option>
                        <option value="-1">禁用</option>
                        <option value="1">待开通</option>
                        <option value="-2">删除</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">图片：</label>
                <div class="col-sm-8">
                    <input name="stationImage" id="stationImage" class="form-control" type="hidden">
                    <a id="url"><img style="width: 90px;height: 90px"></a>
                    <input type="file" id="stationImage4Upload"/>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户所属地区：</label>
                <div class="col-sm-8">
                    <input name="areaId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">服务开始时间(如: 08:00)：</label>
                <div class="col-sm-8">
                    <input name="serviceStartTime" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">服务结束时间(如:20:00)：</label>
                <div class="col-sm-8">
                    <input name="serviceEndTime" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户联系人：</label>
                <div class="col-sm-8">
                    <input name="contactPerson" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户联系人电话：</label>
                <div class="col-sm-8">
                    <input name="contactPersonMobile" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商户标签 ：</label>
                <div class="col-sm-8">
                    <input name="stationTag" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">邀请码：</label>
                <div class="col-sm-8">
                    <input name="invitationCode" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "service/station"
        $("#form-station-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-station-add').serialize());
            }
        }

        $("input[name='modifyTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        // 上传文件
        $("#stationImage4Upload").change(function () {
            var data = new FormData();
            data.append("file", $("#stationImage4Upload")[0].files[0]);
            $.ajax({
                type: "POST",
                url: ctx + "common/upload",
                data: data,
                cache: false,
                contentType: false,
                processData: false,
                dataType: 'json',
                success: function(result) {
                    // alert(JSON.stringify(result))
                    if (result.code == web_status.SUCCESS) {
                        $("#url img").attr("src",ctx + result.fileName)
                        $("#pic").val(result.fileName)
                    }
                },
                error: function(error) {
                    alert("图片上传失败。");
                }
            });
        });
    </script>
</body>
</html>